package cn.stylefeng.guns.sys.modular.system.model;

import cn.stylefeng.guns.sys.core.util.DateUtil;
import cn.stylefeng.roses.core.util.ToolUtil;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Date;
import java.util.List;

@NoArgsConstructor
@Data
public class DdBxdDetail {


    @JsonProperty("create_time")
    private String createTime;
    @JsonProperty("originator_dept_name")
    private String originatorDeptName;
    @JsonProperty("originator_userid")
    private String originatorUserid;
    @JsonProperty("title")
    private String title;
    @JsonProperty("result")
    private String result;
    @JsonProperty("originator_dept_id")
    private String originatorDeptId;
    @JsonProperty("bxdid")
    private String bxdid;
    @JsonProperty("business_id")
    private String businessId;
    @JsonProperty("biz_action")
    private String bizAction;
    @JsonProperty("status")
    private String status;
    @JsonProperty("finish_time")
    private String finishTime;
    @JsonProperty("form_component_values")
    private List<FormComponentValuesDTO> formComponentValues;
    @JsonProperty("attached_process_instance_ids")
    private List<?> attachedProcessInstanceIds;
    @JsonProperty("tasks")
    private List<TasksDTO> tasks;
    @JsonProperty("operation_records")
    private List<OperationRecordsDTO> operationRecords;
    private String sync;

    public String getSync() {
        return sync;
    }

    public void setSync(String sync) {
        this.sync = sync;
    }

    public String getCreateTime() {
        return createTime;
    }

    public void setCreateTime(String createTime) {
        this.createTime = createTime;
    }

    public String getOriginatorDeptName() {
        return originatorDeptName;
    }

    public void setOriginatorDeptName(String originatorDeptName) {
        this.originatorDeptName = originatorDeptName;
    }

    public String getOriginatorUserid() {
        return originatorUserid;
    }

    public void setOriginatorUserid(String originatorUserid) {
        this.originatorUserid = originatorUserid;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getResult() {
        return result;
    }

    public void setResult(String result) {
        this.result = result;
    }

    public String getOriginatorDeptId() {
        return originatorDeptId;
    }

    public void setOriginatorDeptId(String originatorDeptId) {
        this.originatorDeptId = originatorDeptId;
    }

    public String getBxdid() {
        return bxdid;
    }

    public void setBxdid(String bxdid) {
        this.bxdid = bxdid;
    }

    public String getBusinessId() {
        return businessId;
    }

    public void setBusinessId(String businessId) {
        this.businessId = businessId;
    }

    public String getBizAction() {
        return bizAction;
    }

    public void setBizAction(String bizAction) {
        this.bizAction = bizAction;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String getFinishTime() {
        return finishTime;
    }

    public void setFinishTime(String finishTime) {
        this.finishTime = finishTime;
    }

    public List<FormComponentValuesDTO> getFormComponentValues() {
        return formComponentValues;
    }

    public void setFormComponentValues(List<FormComponentValuesDTO> formComponentValues) {
        this.formComponentValues = formComponentValues;
    }

    public List<?> getAttachedProcessInstanceIds() {
        return attachedProcessInstanceIds;
    }

    public void setAttachedProcessInstanceIds(List<?> attachedProcessInstanceIds) {
        this.attachedProcessInstanceIds = attachedProcessInstanceIds;
    }

    public List<TasksDTO> getTasks() {
        return tasks;
    }

    public void setTasks(List<TasksDTO> tasks) {
        this.tasks = tasks;
    }

    public List<OperationRecordsDTO> getOperationRecords() {
        return operationRecords;
    }

    public void setOperationRecords(List<OperationRecordsDTO> operationRecords) {
        this.operationRecords = operationRecords;
    }

    @NoArgsConstructor
    @Data
    public static class FormComponentValuesDTO {

        @JsonProperty("component_type")
        private String componentType;
        @JsonProperty("name")
        private String name;
        @JsonProperty("ext_value")
        private String extValue;
        @JsonProperty("id")
        private String id;
        @JsonProperty("value")
        private String value;

        public String getComponentType() {
            return componentType;
        }

        public void setComponentType(String componentType) {
            this.componentType = componentType;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public String getExtValue() {
            return extValue;
        }

        public void setExtValue(String extValue) {
            this.extValue = extValue;
        }

        public String getId() {
            return id;
        }

        public void setId(String id) {
            this.id = id;
        }

        public String getValue() {
            return value;
        }

        public void setValue(String value) {
            this.value = value;
        }
    }

    @NoArgsConstructor
    @Data
    public static class TasksDTO implements  Comparable<TasksDTO>{

        @JsonProperty("task_status")
        private String taskStatus;
        @JsonProperty("create_time")
        private String createTime;
        @JsonProperty("task_result")
        private String taskResult;
        @JsonProperty("userid")
        private String userid;
        private String userName;
        @JsonProperty("taskid")
        private String taskid;
        @JsonProperty("url")
        private String url;

        public String getTaskStatus() {
            return taskStatus;
        }

        public void setTaskStatus(String taskStatus) {
            this.taskStatus = taskStatus;
        }

        public String getCreateTime() {
            return createTime;
        }

        public void setCreateTime(String createTime) {
            this.createTime = createTime;
        }

        public String getTaskResult() {
            return taskResult;
        }

        public void setTaskResult(String taskResult) {
            this.taskResult = taskResult;
        }

        public String getUserid() {
            return userid;
        }

        public void setUserid(String userid) {
            this.userid = userid;
        }

        public String getTaskid() {
            return taskid;
        }

        public void setTaskid(String taskid) {
            this.taskid = taskid;
        }

        public String getUrl() {
            return url;
        }

        public void setUrl(String url) {
            this.url = url;
        }

        public String getUserName() {
            return userName;
        }

        public void setUserName(String userName) {
            this.userName = userName;
        }

        @Override
        public int compareTo(TasksDTO o) {
            if(ToolUtil.isEmpty(createTime)){
                return 1;
            }
            Date timeToDate = DateUtil.getTimeToDate(createTime);
            Date timeToDate2 = DateUtil.getTimeToDate(o.getCreateTime());
            return timeToDate.compareTo(timeToDate2);
        }
    }

    @NoArgsConstructor
    @Data
    public static class OperationRecordsDTO {

        @JsonProperty("date")
        private String date;
        @JsonProperty("operation_type")
        private String operationType;
        @JsonProperty("operation_result")
        private String operationResult;
        @JsonProperty("userid")
        private String userid;

        public String getDate() {
            return date;
        }

        public void setDate(String date) {
            this.date = date;
        }

        public String getOperationType() {
            return operationType;
        }

        public void setOperationType(String operationType) {
            this.operationType = operationType;
        }

        public String getOperationResult() {
            return operationResult;
        }

        public void setOperationResult(String operationResult) {
            this.operationResult = operationResult;
        }

        public String getUserid() {
            return userid;
        }

        public void setUserid(String userid) {
            this.userid = userid;
        }
    }
}
